With use of http-proxy I looked into the sequence of http requests AVPlayer makes by default for live assets (without having a AVAssetResourceLoaderDelegate set for the asset), and spotted that it makes requests with fixed delay (or it least it seems like that). Apparently renewalDate of AVAssetResourceLoadingContentInformationRequest instance should do the job, however after playing around with it I could not make it work with any values (whether it's a few seconds in future, nearing current time or set in the past) i.e. func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForRenewalOfRequestedResource renewalRequest: AVAssetResourceRenewalRequest) -> Bool method of the delegate does not get called. Another thing which drew my attention is that for live assets all manifests (master and child) have "Expires" http header set to the time of the request (that's probably what AVPlayer itself uses to deduce that the current asset is live and needs to be constantly re-requested), so ended up setting this date for the the master manifest's content information, but it didn't fix the issue either:
if let httpResonse = response as? HTTPURLResponse, let expirationValue = httpResonse.value(forHTTPHeaderField: "Expires") {
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss zzz"
contentInformationRequest.renewalDate = dateFormatter.date(from: expirationValue)
}
For some reason comprehensive documentation which would explain why it doesn't work or any sample codes with use of this property don't exist in my google. Any idea or reference I can refer to in regards to the renewalDate property?